<%--
  Created by IntelliJ IDEA.
  User: ASUS
  Date: 2023/4/25
  Time: 10:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <title>scl统计</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <script src="${pageContext.request.contextPath}/static/js/jquery-3.6.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/layui-v2.7.6/layui/layui.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui-v2.7.6/layui/css/layui.css" media="all">

</head>
<body>

<script type="text/html" id="edit_form">

</script>
<form class="layui-form" action=""  id="saveUserForm" lay-filter="updateUserFormFilter" style="display: none">
    <label>
        回访内容：<input type="text" name="re_con" id="re_con">
    </label>
    <label>
        备注：<input type="text" name="re_bei" id="re_bei">
    </label>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formSaveUser">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<div id="openProductBox" style="display: none; padding: 10px;">
    <table class="layui-hide" id="test" lay-filter="updateUserFormFilter"></table>
</div>
</body>
<div >
    心理健康scl测试结果分析统计表
</div>
<div style="margin-bottom: 20px;">
    <form>
        <label>
            用户名：<input type="text" name="username">
            电话号码：<input type="text" name="tel">

        </label>

        <label>
            <button data-type="query_scl">查询</button>
            <button data-type="query_scl">重置</button>
        </label>
    </form>
</div>


<table class="layui-hide" id="test1" lay-filter="updateUserFormFilter1"></table>
<div>
    心理健康scl存在问题统计表
</div>
<table class="layui-hide" id="test2" lay-filter="updateUserFormFilter2"></table>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="detail">回访</a>

</script>



<script>
    function pan(d){
        let number = d-1.45;
        if(number>-0.45&&number<0.45){
            return "中等水平症状";
        }else if(number<=-0.45&&number>-0.9){
            return "较低水平症状";
        }else if(number<=-0.9){
            return "低症状";
        }else if(number=>0.45&&number<0.9){
            return "较高水平症状";
        }else if(number>=0.9){
            return "高症状";
        }
    }
    layui.use(['table','form','upload'], function(){
        var table = layui.table;
        var form = layui.form;
        table.render({
            elem: '#test1'
            // 数据的格式 data   LayData
            ,url:'${pageContext.request.contextPath}/record?method=findAll'
            ,page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                 layout: ['count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                , curr: 1 //设定初始在第 1 页
                , groups: 1 //只显示 1 个连续页码
                , first: false //不显示首页
                , last: false //不显示尾页
                ,limit:4
        }
            ,cols: [[
                {field:'id', title: '编号', sort: true}
                ,{field:'username', title: '做题人'} //width 支持：数字、百分比和不填写。你还可以通过 minWidth 参数局部定义当前单元格的最小宽度，layui 2.2.1 新增
                ,{field:'tel', title: '电话', sort: true}
                ,{field:'plan_name', title: '计划名', sort: true}
                ,{field:'f1', title: '躯体化', sort: true,templet:function (data) {
                        return pan(data.f1)
                    }}
                ,{field:'f2', title: '强迫', sort: true,templet:function (data) {
                        return pan(data.f2)
                    }}
                ,{field:'f3', title: '人际敏感', sort: true,templet:function (data) {
                        return pan(data.f3)
                    }}
                ,{field:'f4', title: '抑郁', sort: true,templet:function (data) {
                        return pan(data.f4)
                    }}
                ,{field:'f5', title: '焦虑', sort: true,templet:function (data) {
                        return pan(data.f5)
                    }}
                ,{field:'f6', title: '敌对', sort: true,templet:function (data) {
                        return pan(data.f6)
                    }}
                ,{field:'f7', title: '恐怖', sort: true,templet:function (data) {
                        return pan(data.f7)
                    }}
                ,{field:'f8', title: '偏执', sort: true,templet:function (data) {
                        return pan(data.f8)
                    }}
                ,{field:'f9', title: '精神病', sort: true,templet:function (data) {
                        return pan(data.f9)
                    }}
                ,{field:'f10', title: '睡眠及饮食', sort: true,templet:function (data) {
                        return pan(data.f10)
                    }}
                ,{fixed: 'right', align:'center',title: '操作',toolbar: '#barDemo'}
            ]]
        });
        table.render({
            elem: '#test2'
            // 数据的格式 data   LayData
            ,url:'${pageContext.request.contextPath}/problemServlet'
            ,cols: [[
                {field:'pid', title: '编号', sort: true}
                ,{field:'num', title: '人数', sort: true}
                ,{field:'type', title: '症状类型', sort: true}
            ]]
        });



        //监听工具条
        table.on('tool(updateUserFormFilter1)', function(obj){
            var data = obj.data

            if(obj.event === 'detail'){
                layer.open({
                    title: '回访',
                    type: 1,
                    content: $('#saveUserForm'),
                    area: ['500px', '300px']
                });
                form.val('updateUserFormFilter', {
                    "re_con":""
                    ,"re_bei": ""
                });
                form.on('submit(formSaveUser)', function(){
                    $.ajax({
                        url:"${pageContext.request.contextPath}/TabReturnServlet?method=add",
                        dataType:"JSON",
                        data:{
                            "id":data.id
                            ,"name":data.username
                            ,"tel":data.tel
                            ,"plan_name":data.plan_name
                            ,"re_con":$("#re_con").val()
                            ,"re_bei":$("#re_bei").val()

                        },
                        success:function (ret) {
                            if(ret.code===0){
                                layer.closeAll();
                            }
                        }
                    });
                    return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可
                });
            }
        });

    });


</script>

</html>
